<?php
class Commentmanager_Model_Pagedecision implements Commentmanager_Model_Mainable{
    
    private $action_handler;
    private $core_controller_csrftoken;
    private $get_status_data;
    
    public function main(array $variables = null){
        switch($variables['get']['page']){
            case 'edytuj-komentarz':
                return $this->edit_comment($variables);
                break;
            case 'aktualizuj-komentarz':
                return $this->update_comment($variables);
                break;
            default:
                return $this->default_action();
                break;
        }
    }
    
    private function update_comment(array $variables = null){
        $this->action_handler = new Commentmanager_Model_Updatecommentstatus;
        return $this->action_handler->main($variables);
    }
    
    private function edit_comment(array $variables = null){
        $page = $this->get_other_data($variables);
        $this->action_handler = new Commentmanager_Data_Getcurrentcomment;
        $page['content'] = $this->action_handler->main($variables);
        return $page;
    }
    
    private function default_action(array $variables = null){
        unset($variables['get']);
        $this->action_handler = new Commentmanager_Model_Commentmanager;
        return $this->action_handler->main($variables);
    }
    
    private function get_other_data(array $variables = null){
        $this->get_status_data = new Accountsstatus_Data_Getaccountsstatus;
        $this->core_controller_csrftoken = new Core_Controller_Csrftoken;
        $page['template'] = WEB_ROOT_FOLDER."commentmanager/views/editcomment.php";
        $page['status'] = $this->get_status_data->main($variables);
        $page['csrf_token'] = $this->core_controller_csrftoken->main($variables);
        return $page;
    }
    
}
